﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:sys="clr-namespace:System;assembly=mscorlib">

    <!--x:Key="ScrollBarThumb" TargetType="{x:Type Thumb}"-->
    <SolidColorBrush x:Key="ThumbBorderBackground" Color="#FFAAAAAA"/>
    <SolidColorBrush x:Key="ThumbMouseOverBackground" Color="#FF606060"/>
    <SolidColorBrush x:Key="ThumbDraggingBackground" Color="#FF606060"/>

    <!--x:Key="ScrollBarStyle1" TargetType="{x:Type ScrollBar}"-->
    <!--1,垂直与水平值相反(默认UpButton)-->
    <sys:Double x:Key="RepeatButtonPathWidth">8</sys:Double>
    <sys:Double x:Key="RepeatButtonPathHeight">8</sys:Double>
    <sys:Double x:Key="ScrollBarWidth">10</sys:Double>
    <sys:Double x:Key="ScrollBarMinWidth">10</sys:Double>
    <sys:Double x:Key="ScrollBarHeight">10</sys:Double>
    <sys:Double x:Key="ScrollBarMinHeight">10</sys:Double>
    <!--2,垂直与水平值一样-->
    <SolidColorBrush x:Key="DefaultColor" Color="#FFAAAAAA"/>
    <SolidColorBrush x:Key="MouseOverColor" Color="#FF606060"/>
    <SolidColorBrush x:Key="EnabledColor" Color="#FF808080"/>
    <SolidColorBrush x:Key="ScrollBarBackground" Color="#FFF1F1F1"/>

    <Style x:Key="RepeatButtonStyle" TargetType="{x:Type RepeatButton}">
        <Setter Property="Stylus.IsPressAndHoldEnabled" Value="false"/>
        <Setter Property="HorizontalContentAlignment" Value="Center"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type RepeatButton}">
                    <Border x:Name="border" CornerRadius="0">
                        <Grid x:Name="grid" Background="#00000000">
                            <ContentPresenter x:Name="contentPresenter" 
                                              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                              Margin="{TemplateBinding Padding}"
                                              RecognizesAccessKey="True" 
                                              SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" 
                                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
                            </ContentPresenter>
                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="VerticalScrollBarPageButton" TargetType="{x:Type RepeatButton}">
        <Setter Property="OverridesDefaultStyle" Value="true"/>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="Focusable" Value="false"/>
        <Setter Property="IsTabStop" Value="false"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type RepeatButton}">
                    <Rectangle Fill="{TemplateBinding Background}" Height="{TemplateBinding Height}" Width="{TemplateBinding Width}"/>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style x:Key="ScrollBarThumb" TargetType="{x:Type Thumb}">
        <Setter Property="OverridesDefaultStyle" Value="true"/>
        <Setter Property="IsTabStop" Value="false"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Thumb}">
                    <Border x:Name="border" Background="{StaticResource ThumbBorderBackground}" CornerRadius="0"/>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="Background" TargetName="border" Value="{StaticResource ThumbMouseOverBackground}" />
                        </Trigger>
                        <Trigger Property="IsDragging" Value="True">
                            <Setter Property="Background" TargetName="border" Value="{StaticResource ThumbDraggingBackground}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style x:Key="HorizontalScrollBarPageButton" TargetType="{x:Type RepeatButton}">
        <Setter Property="OverridesDefaultStyle" Value="true"/>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="Focusable" Value="false"/>
        <Setter Property="IsTabStop" Value="false"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type RepeatButton}">
                    <Rectangle Fill="{TemplateBinding Background}" Height="{TemplateBinding Height}" Width="{TemplateBinding Width}"/>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style  TargetType="{x:Type ScrollBar}">
        <Setter Property="Background" Value="{StaticResource ScrollBarBackground}"/>
        <Setter Property="Width" Value="{DynamicResource ScrollBarWidth}"/>
        <Setter Property="MinWidth" Value="{DynamicResource ScrollBarMinWidth}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ScrollBar}">
                    <Grid x:Name="Bg" SnapsToDevicePixels="true">
                        <Grid.RowDefinitions>
                            <RowDefinition MaxHeight="{DynamicResource {x:Static SystemParameters.VerticalScrollBarButtonHeightKey}}"/>
                            <RowDefinition Height="0"/>
                            <RowDefinition Height="0.00001*"/>
                            <RowDefinition Height="0"/>
                            <RowDefinition MaxHeight="{DynamicResource {x:Static SystemParameters.VerticalScrollBarButtonHeightKey}}"/>
                        </Grid.RowDefinitions>
                        <RepeatButton x:Name="upButton" Command="{x:Static ScrollBar.LineUpCommand}" HorizontalContentAlignment="Center" Style="{DynamicResource RepeatButtonStyle}" IsEnabled="{TemplateBinding IsMouseOver}">
                            <Path x:Name="upPath" Height="{StaticResource RepeatButtonPathHeight}" Width="{StaticResource RepeatButtonPathWidth}" Stretch="Fill" Fill="{Binding Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type RepeatButton}}}" Data="M 0,0 8,0 4,-15 Z"/>
                        </RepeatButton>
                        <Border x:Name="border" Grid.Row="2" CornerRadius="0" Background="{StaticResource ScrollBarBackground}">
                            <Track x:Name="PART_Track" IsDirectionReversed="true" IsEnabled="{TemplateBinding IsMouseOver}" OpacityMask="#FFC8C5C5">
                                <Track.DecreaseRepeatButton>
                                    <RepeatButton Command="{x:Static ScrollBar.PageUpCommand}" Style="{StaticResource VerticalScrollBarPageButton}"/>
                                </Track.DecreaseRepeatButton>
                                <Track.IncreaseRepeatButton>
                                    <RepeatButton Command="{x:Static ScrollBar.PageDownCommand}" Style="{StaticResource VerticalScrollBarPageButton}"/>
                                </Track.IncreaseRepeatButton>
                                <Track.Thumb>
                                    <Thumb Style="{StaticResource ScrollBarThumb}"/>
                                </Track.Thumb>
                            </Track>
                        </Border>
                        <RepeatButton x:Name="downButton" Command="{x:Static ScrollBar.LineDownCommand}"  Grid.Row="4" Style="{DynamicResource RepeatButtonStyle}" IsEnabled="{TemplateBinding IsMouseOver}">
                            <Path x:Name="downPath" Height="{StaticResource RepeatButtonPathHeight}" Width="{StaticResource RepeatButtonPathWidth}" Stretch="Fill" Fill="{Binding Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type RepeatButton}}}" Data="M 0,0 8,0 4,15 Z"/>
                        </RepeatButton>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="True">
                            <!--默认-->
                            <Setter Property="Foreground" TargetName="upButton" Value="{StaticResource DefaultColor}"/>
                            <Setter Property="Foreground" TargetName="downButton" Value="{StaticResource DefaultColor}"/>
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="True">
                            <!--MouseOver-->
                            <Setter Property="Foreground" TargetName="upButton" Value="{StaticResource MouseOverColor}"/>
                            <Setter Property="Foreground" TargetName="downButton" Value="{StaticResource MouseOverColor}"/>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="false">
                            <!--无效-->
                            <Setter Property="Foreground" TargetName="upButton" Value="{StaticResource EnabledColor}"/>
                            <Setter Property="Foreground" TargetName="downButton" Value="{StaticResource EnabledColor}"/>
                            <Setter Property="Background" TargetName="Bg" Value="Transparent"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <Trigger Property="Orientation" Value="Horizontal">
                <Setter Property="Background" Value="{StaticResource ScrollBarBackground}"/>
                <Setter Property="Width" Value="Auto"/>
                <Setter Property="Height" Value="{DynamicResource ScrollBarHeight}"/>
                <Setter Property="MinHeight" Value="{DynamicResource ScrollBarMinHeight}"/>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type ScrollBar}">
                            <Grid x:Name="Bg" SnapsToDevicePixels="true">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition MaxWidth="{DynamicResource {x:Static SystemParameters.HorizontalScrollBarButtonWidthKey}}"/>
                                    <ColumnDefinition Width="0"/>
                                    <ColumnDefinition Width="0.00001*"/>
                                    <ColumnDefinition Width="0"/>
                                    <ColumnDefinition MaxWidth="{DynamicResource {x:Static SystemParameters.HorizontalScrollBarButtonWidthKey}}"/>
                                </Grid.ColumnDefinitions>
                                <RepeatButton x:Name="leftButton" Command="{x:Static ScrollBar.LineLeftCommand}" IsEnabled="{TemplateBinding IsMouseOver}" Style="{DynamicResource RepeatButtonStyle}">
                                    <Path x:Name="leftPath" Height="{StaticResource RepeatButtonPathWidth}" Width="{StaticResource RepeatButtonPathHeight}" Stretch="Fill" Fill="{Binding Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type RepeatButton}}}" Data="M 0,0 0,-8 -15,-4 Z"/>
                                </RepeatButton>
                                <Border x:Name="border" Grid.Column="2" CornerRadius="0" Background="{StaticResource ScrollBarBackground}">
                                    <Track x:Name="PART_Track" IsEnabled="{TemplateBinding IsMouseOver}">
                                        <Track.DecreaseRepeatButton>
                                            <RepeatButton Command="{x:Static ScrollBar.PageLeftCommand}" Style="{StaticResource HorizontalScrollBarPageButton}"/>
                                        </Track.DecreaseRepeatButton>
                                        <Track.IncreaseRepeatButton>
                                            <RepeatButton Command="{x:Static ScrollBar.PageRightCommand}" Style="{StaticResource HorizontalScrollBarPageButton}"/>
                                        </Track.IncreaseRepeatButton>
                                        <Track.Thumb>
                                            <Thumb Style="{StaticResource ScrollBarThumb}"/>
                                        </Track.Thumb>
                                    </Track>
                                </Border>
                                <RepeatButton x:Name="rightButton" Grid.Column="4" Command="{x:Static ScrollBar.LineRightCommand}" IsEnabled="{TemplateBinding IsMouseOver}" Style="{DynamicResource RepeatButtonStyle}">
                                    <Path x:Name="rightPath" Height="{StaticResource RepeatButtonPathWidth}" Width="{StaticResource RepeatButtonPathHeight}" Stretch="Fill" Fill="{Binding Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type RepeatButton}}}" Data="M 0,0 0,-8 15,-4 Z"/>
                                </RepeatButton>
                            </Grid>

                            <ControlTemplate.Triggers>
                                <Trigger Property="IsEnabled" Value="True">
                                    <!--默认-->
                                    <Setter Property="Foreground" TargetName="leftButton" Value="{StaticResource DefaultColor}"/>
                                    <Setter Property="Foreground" TargetName="rightButton" Value="{StaticResource DefaultColor}"/>
                                </Trigger>
                                <Trigger Property="IsMouseOver" Value="True">
                                    <!--MouseOver-->
                                    <Setter Property="Foreground" TargetName="leftButton" Value="{StaticResource MouseOverColor}"/>
                                    <Setter Property="Foreground" TargetName="rightButton" Value="{StaticResource MouseOverColor}"/>
                                </Trigger>
                                <Trigger Property="IsEnabled" Value="false">
                                    <!--无效-->
                                    <Setter Property="Foreground" TargetName="leftButton" Value="{StaticResource EnabledColor}"/>
                                    <Setter Property="Foreground" TargetName="rightButton" Value="{StaticResource EnabledColor}"/>
                                    <Setter Property="Background" TargetName="Bg" Value="Transparent"/>
                                </Trigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Trigger>
        </Style.Triggers>
    </Style>

    <!--总样式x:Key="ScrollViewerStyle"-->
    <Style TargetType="{x:Type ScrollViewer}">
        <Setter Property="OverridesDefaultStyle" Value="True"/>
        <Setter Property="BorderBrush" Value="{DynamicResource Slider_Color}"/>
        <Setter Property="BorderThickness" Value="0"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ScrollViewer}">
                    <Border Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}">
                        <Grid x:Name="Grid">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*"/>
                                <ColumnDefinition Width="Auto"/>
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="*"/>
                                <RowDefinition Height="Auto"/>
                            </Grid.RowDefinitions>
                            <ScrollBar x:Name="PART_VerticalScrollBar" AutomationProperties.AutomationId="VerticalScrollBar" Cursor="Arrow" Grid.Column="1" Maximum="{TemplateBinding ScrollableHeight}" Minimum="0" Grid.Row="0" Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" Value="{Binding VerticalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" ViewportSize="{TemplateBinding ViewportHeight}"/>
                            <ScrollBar x:Name="PART_HorizontalScrollBar" AutomationProperties.AutomationId="HorizontalScrollBar" Cursor="Arrow" Grid.Column="0" Maximum="{TemplateBinding ScrollableWidth}" Minimum="0" Orientation="Horizontal" Grid.Row="1" Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}" Value="{Binding HorizontalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" ViewportSize="{TemplateBinding ViewportWidth}"/>
                            <ScrollContentPresenter x:Name="PART_ScrollContentPresenter" CanContentScroll="{TemplateBinding ScrollViewer.CanContentScroll}" CanHorizontallyScroll="False" CanVerticallyScroll="False" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" Grid.Column="0" Margin="{TemplateBinding Padding}" Grid.Row="0"/>
                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>